import tkinter as tk

class ATestResult:
    intVar=0
    strVar=''
    boolVar=False


    def __class_getitem__(cls, item):
        return cls.__dict__[item]

    @classmethod
    def setattr(cls, key, value):
        # 通过这种方式修改类变量
        setattr(cls, key, value)
        # cls.__dict__[key] = value




def add(num1,num2):
    return num1+num2

def btn_event():
    text = entry.get()
    print('获取文本为：', text)
    res = add(2,3)
    print(res)
    print(ATestResult.__dict__)
    ATestResult.setattr('intVar', 1)

    # ATestResult.intVar = 1
    print(ATestResult['intVar'])

root = tk.Tk()
tk.Label(root, text='输入类名和变量:').pack()
entry = tk.Entry(root)
entry.pack()

tk.Button(root, text='运行',command=btn_event).pack()

root.mainloop()
